<template>
	<view class="main">
		<view class="top">
			<view class="card">
				<p>会员费</p>
				<p><span>{{Number(price).toFixed(2)}} </span> 元</p>
				<p>您还未开通会员，开通立享尊享服务</p>
				<button class="btn" @click="openVipHandle">立即开通</button>
			</view>
			<view class="tip">
				<image src="../../../static/test/tip.png" mode=""></image>
				<span>开通会员后优享工人优先排序等尊享服务</span>
			</view>
		</view>
		<button class="openvipbtn" @click="openVipHandle">立即开通</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				price: 0
			}
		},
		mounted() {
			this.getVipPrice()
		},
		methods: {
			// 获取会员支付金额
			async getVipPrice() {
				await uni.request({
					url: '/worker/pay_money',
					method: 'POST',
					success: (res) => {
						if (res.res.code == 1) {
							this.price = res.res.data.money
						} else {
							this.$wanlshop.msg(res.msg || '请求失败！');
						}
					}
				});
			},
			// 开通会员
			async openVipHandle() {
				let data = {
					money: this.price
				}
				await uni.request({
					url: '/worker/pay',
					method: 'POST',
					data,
					success: (res) => {
						if (res.res.code == 1) {
						} else {
							this.$wanlshop.msg(res.msg || '请求失败！');
						}
					}
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	.main {
		height: calc(100vh - 200rpx);
		display: flex;
		flex-direction: column;
		justify-content: space-between;

		.top {
			.card {
				width: 100%;
				padding: 54rpx 74rpx 80rpx;
				background: url('@/static/test/vipback.png');
				background-size: cover;
				background-repeat: no-repeat;

				p {
					font-family: PingFangSC, PingFang SC;
					font-size: 26rpx;
					line-height: 60rpx;
					color: #FE6600;

					span {
						font-size: 66rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
					}
				}

				.btn {
					width: 100%;
					height: 88rpx;
					background-color: #FE6600;
					border-radius: 44rpx;
					margin-top: 40rpx;
					line-height: 80rpx;
					border: none;
					color: #fff;
					font-size: 30rpx;
				}

			}

			.tip {
				display: flex;
				align-items: center;
				padding: 0 34rpx;

				image {
					width: 28rpx;
					height: 28rpx;
					margin-right: 10rpx;
				}

				span {
					color: #666666;
					font-size: 28rpx
				}
			}
		}

		.openvipbtn {
			margin: 0 34rpx;
			height: 88rpx;
			background-color: #FE6600;
			border-radius: 44rpx;
			margin-top: 40rpx;
			line-height: 80rpx;
			border: none;
			color: #fff;
			font-size: 30rpx;
		}
	}
</style>
